package com.lxl.testHd.wc.one;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author ：e_lixilin
 * @date ：2022/2/21 10:32
 * @description：
 * @modified By：
 */
public class MyReducer extends Reducer<Text, IntWritable,Text, IntWritable> {

    Text outKey = new Text();
    IntWritable outValue = new IntWritable();
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        outKey.set(key.toString());
        int count =0;
        for (IntWritable value : values) {
            count += value.get();
        }
        outValue.set(count);
        context.write(outKey,outValue);
    }
}
